package com.ruoyi.project.warehouseSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouseSystem.domain.CIntwarehouse;
import com.ruoyi.project.warehouseSystem.service.ICIntwarehouseService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 入库的申请Controller
 * 
 * @author wangshuo
 * @date 2021-07-18
 */
@RestController
@RequestMapping("/warehouseSystem/rkapplay")
public class CIntwarehouseController extends BaseController
{
    @Autowired
    private ICIntwarehouseService cIntwarehouseService;

    /**
     * 查询入库的申请列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:list')")
    @GetMapping("/list")
    public TableDataInfo list(CIntwarehouse cIntwarehouse)
    {
        startPage();
        List<CIntwarehouse> list = cIntwarehouseService.selectCIntwarehouseList(cIntwarehouse);
        return getDataTable(list);
    }

    /**
     * 导出入库的申请列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:export')")
    @Log(title = "入库的申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CIntwarehouse cIntwarehouse)
    {
        List<CIntwarehouse> list = cIntwarehouseService.selectCIntwarehouseList(cIntwarehouse);
        ExcelUtil<CIntwarehouse> util = new ExcelUtil<CIntwarehouse>(CIntwarehouse.class);
        return util.exportExcel(list, "rkapplay");
    }

    /**
     * 获取入库的申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(cIntwarehouseService.selectCIntwarehouseById(id));
    }

    /**
     * 新增入库的申请
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:add')")
    @Log(title = "入库的申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CIntwarehouse cIntwarehouse)
    {
        return toAjax(cIntwarehouseService.insertCIntwarehouse(cIntwarehouse));
    }

    /**
     * 修改入库的申请
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:edit')")
    @Log(title = "入库的申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CIntwarehouse cIntwarehouse)
    {
        return toAjax(cIntwarehouseService.updateCIntwarehouse(cIntwarehouse));
    }

    /**
     * 删除入库的申请
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:rkapplay:remove')")
    @Log(title = "入库的申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cIntwarehouseService.deleteCIntwarehouseByIds(ids));
    }
}
